import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import { loadEnv } from "vite";
import { resolve } from "path";
export default defineConfig((props) => {
  // eslint-disable-next-line no-undef
  const env = loadEnv(props.mode, process.cwd());
  return {
    base: "./",
    plugins: [vue(), vueJsx()],
    server: {
      host: "0.0.0.0",
      // port: 3000,
      open: true,
      proxy: {
        [env.VITE_PATHNAME]: {
          target: env.VITE_ORIGIN,
          changeOrigin: true,
          ws: true,
          rewrite: (path) => path.replace(env.VITE_PATHNAME, ""),
        },
      },
    },
    resolve: {
      alias: {
        // eslint-disable-next-line no-undef
        "@": resolve(__dirname, "src"),
      },
    },
  };
});
